<%@ page language="java"
	import="java.util.*,news.dao.*,news.pojo.*,news.util.*"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<link href="css/read.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function checkComment() {
		var cauthor = document.getElementById("cauthor");
		var content = document.getElementById("ccontent");
		if (cauthor.value == "") {
			alert("用户名不能为空！！");
			return false;
		} else if (content.value == "") {
			alert("评论内容不能为空！！");
			return false;
		}
		return true;
	}

function souye(){
location='home.jsp';
}

</script>
</head>


<div id="container">



	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
	<jsp:include page="/leftServlet"></jsp:include>


	<div class="main">
		<div class="class_type">
			<img src="images/class_type.gif" alt="新闻中心" onclick="souye()" />
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>点击图片新闻中心回到主页</span>
		</div>
		<div class="content">
			<ul class="classlist">
				<table width="80%" align="center">
					<tr width="100%">
						<%--  <%
          Integer nid=Integer.parseInt(request.getParameter("nid"));         
          NewsDao ndo=new NewsDao();
          News nn2=ndo.get(nid);
           %> --%>
						<c:out value=""></c:out>
						
							<img src="${news.npicPath}" height="200px"/>
						<td colspan="2" align="center"><c:out value="${news.ntitle }"
								default="错误！！！" escapeXml="false"></c:out></td>
					</tr>
					<tr>
						<td colspan="2"><hr /></td>
					</tr>
					<tr>
						<td align="center">作者：<c:out value="${news.nauthor}"></c:out>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							</a></td>
						<td align="left">发布时间：<fmt:formatDate value="${news.ncreateDate }" pattern="yyyy-MM-dd HH:mm"/></td>
					</tr>
					<tr>
						<td colspan="2" align="center"></td>
					</tr>
					<tr>
						<td colspan="2">
							<p>

								<textarea name="nnncontent" id="ncontent" cols="90" rows="10"
									readonly="readonly"><c:out value="${news.ncontent }"></c:out></textarea>
							</p>
						</td>
					</tr>
					<tr>
						<td colspan="2"><hr /></td>
					</tr>
				</table>
			</ul>
			<ul class="classlist">
				<table width="80%" align="center">
					<td colspan="6"><c:choose>
							<c:when test="${empty clist }">
					暂无评论，快抢沙发！
					</c:when>
							<c:otherwise>
								<h3 style="color:green">神评榜:</h3>
								<c:forEach items="${clist }" var="clist" varStatus="s">
									<div>
										用户：<span style="color:red">${clist.cauthor}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										时间：<span style="color:orange"><fmt:formatDate value="${clist.cdate }" pattern="yyyy-MM-dd HH:mm"/></span>&nbsp;&nbsp;
										IP：<span style="color:purple">${clist.cip }</span>
									</div>
									<div>
										内容：<span style="color:blue">${clist.ccontent}</span>
									</div>
									<br>
									<hr>
								</c:forEach>

							</c:otherwise>
						</c:choose></td>
					<tr>
						<td colspan="6"><hr /></td>
					</tr>


				</table>
			</ul>
			<ul class="classlist">
				<form
					action="addcommentServlet?opr=addComment&nid=${news.nid }"
					method="post" onSubmit="return checkComment()">
					<table width="80%" align="center">
						<tr>
							<td>评 论</td>
						</tr>
						<tr>
							<td>用户名：</td>
							<td><input id="cauthor" name="cauthor" value="无名小辈" /> IP：
							<%-- 	<%
								String ip = request.getRemoteAddr();
							%> --%> <input name="cip" id="cip" value=""
								readonly="readonly" style="border:0px;" /></td>
						</tr>
						<tr>
							<td colspan="2"><textarea name="ccontent" id="ccontent"
									cols="70" rows="10"></textarea></td>
						</tr>
						<td><input name="submit" value="发  表" type="submit" /></td>
					</table>
				</form>
			</ul>
		</div>
	</div>
</div>
<div>
	<%-- 
<%

int addresult=100;
try{
request.setCharacterEncoding("UTF-8");
addresult=Integer.parseInt(request.getParameter("addc"));
}catch(Exception e){}
if(addresult==1){%>
alert(添加成功！！！"");
<%
}else if(addresult==100){%>
<%
}else{%>

alert("失败！");
<% 
}


 %>
 --%>

</div>

<%@ include file="footer.jsp"%>
</body>
</html>

</html>